def fibonacci_loop(n_terms):
    """
    循环实现：获取斐波那契数列前n_terms项
    :param n_terms: 要生成的项数（正整数）
    :return: 斐波那契数列列表
    """
    if not isinstance(n_terms, int) or n_terms <= 0:
        raise ValueError("项数必须是正整数！")
    fib_sequence = [1, 1]
    if n_terms == 1:
        return [1]  
    elif n_terms == 2:
        return fib_sequence  
    
    for i in range(2, n_terms):
        next_term = fib_sequence[i-1] + fib_sequence[i-2]
        fib_sequence.append(next_term)
    
    return fib_sequence
if __name__ == "__main__":
    terms = 20
    result = fibonacci_loop(terms)
    print(f"斐波那契数列前{terms}项：")
    print(result)
